<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta charset="utf-8">
	<title>修改专家信息</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="../layui/css/layui.css" media="all">
	<link rel="stylesheet" href="../css/public.css"/>
	<style type="text/css">
		.adminuser-con .not_border_left {
			border-left: none !important;
		}
		
		.adminuser-con .layui-form-select dl dd.layui-this {
			background-color: #1E9FFF !important;
		}
		.adminuser-con {
			padding: 10px 15px 15px 15px;
			margin-bottom: 20px;
		}
		.adminuser-con .layui-table-tool{
			margin-bottom: 10px;
		}
		.adminuser-con .layui-table-box{
			border: 1px solid #eee;
		}
		.adminuser-con .layui-table-body table tbody .layui-table-hover{
			background: #fffdd3 !important;
		}
		.adminuser-con .layui-table-body table tbody .layui-table-click{
			background: #fdef9b !important;
		}
		.adminuser-con .layui-form-item .layui-input-block .required {
			color: #ffb800; 
			font-size: 32px; 
			float: left; 
			margin-left: 5px; 
			margin-top: 15px;
			position: absolute;
			right: -15px;
		}
		.adminuser-con .layui-table-view{
			border: none !important;
		}
		
		/* 修改专家信息弹窗样式 */
		.editAdminUserLayer-con{
			display: none;
			padding:10px 15px 15px 15px;
			margin-bottom: 40px;
		}
		.editAdminUserLayer-con .top-inp{
			margin-left: 20px;
		}
		.editAdminUserLayer-con .from-con{
			margin: auto;
			background-color: #E2E2E2;
			padding: 10px;
			overflow: hidden;
		}
		.editAdminUserLayer-con .from-con .layui-form-item{
			margin:20px 0 ;
		}
		.editAdminUserLayer-con .not_border_left {
			border-left: none !important;
		}
		.editAdminUserLayer-con .layui-form-item .layui-input-block .required {
			color: #ffb800; 
			font-size: 32px; 
			float: left; 
			margin-left: 5px; 
			margin-top: 5px;
			position: absolute;
			right: -15px;
		}
		.editAdminUserLayer-con .layui-form-select dl dd.layui-this{
			background-color: #1E9FFF !important;
		}
		 .editAdminUserLayer-con .layui-btn{
			background-color: #1E9FFF !important;
		}
		.editAdminUserLayer-con .layui-form-select dl{
			max-height:230px !important;
		}
		.editAdminUserLayer-con .layui-row .layui-col-xs4{
			text-align: center;
		}
		.editAdminUserLayer-con .layui-row .layui-col-xs4 .layui-upload-img{
			width: 200px;
			height: 150px;
			border: 1px solid #e6e6e6;
			background-color: #FFFFFF;
		}
	</style>
</head>
<body>
	<div class="adminuser-con">
	
		<!-- 修改后台用户信息弹窗Start -->
		<div class="editAdminUserLayer-con" id="editAdminUserLayer">
			<div class="from-con">
				<div style="width: 80%;">
				<form class="layui-form" action="" id="addadminuser">
				  	<div class="layui-form-item">
					    <label class="layui-form-label">用户名</label>
					    <div class="layui-input-block">
					      <input id="adminusername" disabled type="text" style="float: left;position: relative;" name="adminusername" class="layui-input">
					      <i class="required">*</i>
					    </div>
				  	</div>
					<div class="layui-form-item">
					    <label class="layui-form-label">真实姓名</label>
					    <div class="layui-input-block">
					    	<input id="adminrealname" name="adminrealname" type="text" style="float: left;position: relative;" class="layui-input" placeholder="请输入真实姓名" lay-verify="required" autocomplete="off">
					    	<i class="required">*</i>
					    </div>
					</div>
					<div class="layui-form-item">
					    <label class="layui-form-label">联系电话</label>
					    <div class="layui-input-block">
					    	<input id="phone" name="phone" type="tel" style="float: left;position: relative;" class="layui-input" autocomplete="off">
					    	<i class="required">*</i>
					    </div>
					</div>
			  		<div class="layui-form-item">
					    <div class="layui-input-block">
					      <button type="button" id="btnaddadminuser" lay-submit="" lay-filter="btnaddadminuser" class="layui-btn" style="float: right;"> 保  存 </button>
					    </div>
			  		</div>
				</form>
				</div>
			</div>
		</div>
		<!-- 修改后台用户信息弹窗End -->
		
		<!-- 条件查询区Start -->
		<blockquote class="layui-elem-quote not_border_left">
			<form class="layui-form" action="">
			<div class="layui-inline">
				<div class="layui-input-inline">
					<select name="backrolemodel" id="backrolemodel" lay-filter="backrolemodel">	
						<option value="00">请选择角色</option>							
					</select>
				</div>	
				<div class="layui-input-inline">
					<input id="seleUserName" name="seleUserName" type="text" autocomplete="off" placeholder="请输入账号或真实姓名" class="layui-input">
				</div>
				<div class="layui-inline">
					<button id="btnseladminuser" type="button" class="layui-btn layui-bg-blue">查询</button>	
				</div>
			</div>	
			</form>	
		</blockquote>
		
		<table class="layui-hide" id="tabadminuser" lay-filter="tabadminuser"></table>

		<script type="text/html" id="barDemo">
			<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="editadminuser">编辑</a>
			<a class="layui-btn layui-btn-xs layui-bg-red" lay-event="deladminuser">删除</a>
		</script>
		
		
	</div>
	<script src="../js/jquery-3.3.1.js"></script>
	<script src="../layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript">
		layui.use(['table','form'], function() {
			var table = layui.table;
			var form = layui.form;
			
			//加载角色类型
			$.ajax({
				type : 'get',
				url : '../sysbackmanage/getallbackrolelist',
				datatype : 'json',
				success : function(roledata) {
					if (roledata.code == 0) {
						var str = "";
						for(var i = 0; i < roledata.count; i++){
							str += '<option value=' + roledata.data[i].id + '>'+ roledata.data[i].name +'</option>';
						}
						$("#backrolemodel").append(str);
						form.render();
					}
					else{
						layer.msg("角色信息获取失败");
					}
				},
				error : function() {
			 		layer.msg("角色信息获取失败");
				}
			});
			
			table.render({
				elem: '#tabadminuser',
				id:'adminuserid',
				url: '../sysadminusermanager/getadminuserbystrwhere',
				title: '后台用户信息表',
				height:"full-125",
				skin: 'line',
				even: true,
				cols: [
					[{
						field: 'userid',
						title: '账号',
						align: "center"
					}, {
						field: 'realname',
						title: '真实姓名',
						align: "center"
					}, {
						field: 'name',
						title: '角色',
						align: "center"
					}, {
						field: 'mobile',
						title: '联系电话',
						align: "center"
					}, {
						field: 'createtime',
						title: '注册时间',
						align: "center"
					},{
						title: '操作',
						toolbar: '#barDemo',
						align: "center"
					}]
				], page: {
					layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
					groups: 5,
					limit: 10,
					theme: '#1E9FFF',						
				}
			});
			
			$("#btnseladminuser").click(function(){
				var roleid=$("#backrolemodel").val();
				var username=$("#seleUserName").val();
				if(roleid==00 || roleid=='null' || roleid==undefined){
					roleid="";
				}
				if(username==undefined){
					username="";
				}
				table.render({
					elem: '#tabadminuser',
					id:'adminuserid',
					url: '../sysadminusermanager/getadminuserbystrwhere?roldid='+roleid+"&username="+username,
					title: '后台用户信息表',
					height:"full-125",
					skin: 'line',
					even: true,
					cols: [
						[{
							field: 'userid',
							title: '账号',
							align: "center"
						}, {
							field: 'realname',
							title: '真实姓名',
							align: "center"
						}, {
							field: 'name',
							title: '角色',
							align: "center"
						}, {
							field: 'mobile',
							title: '联系电话',
							align: "center"
						}, {
							field: 'createtime',
							title: '注册时间',
							align: "center"
						},{
							title: '操作',
							toolbar: '#barDemo',
							align: "center"
						}]
					], page: {
						layout: ['prev', 'page', 'next', 'skip', 'count', 'limit'],
						groups: 5,
						limit: 10,
						theme: '#1E9FFF',						
					}
				});
			});
			
		    
			//工具栏事件
		    table.on('tool(tabadminuser)', function(obj){
			    var data = obj.data;
				/*修改后台用户信息 */
			    if(obj.event === 'editadminuser'){
			    	$("#adminusername").val(data.userid);
					$("#adminrealname").val(data.realname);
					$("#phone").val(data.mobile);
					var index=layer.open({
						type: 1, 
					    title: '修改后台用户信息',
				        area: ['830px', '95%'],
				        shade: 0.8,
				        maxmin: true,
				        content: $('#editAdminUserLayer'),
				        cancel: function(){ 
						   $(".editAdminUserLayer-con").css("display","none");
						}
				    });
			    	layer.full(index);
			    	
			    	/*点击修改用户信息*/
					form.on('submit(btnaddadminuser)', function(pardata){
						var adminuserid=$("#adminusername").val().trim();
						var adminrealname=$("#adminrealname").val().trim();
						var phone=$("#phone").val().trim();
						$.ajax({
							url: '../sysadminusermanager/updateadminuser?userid='+adminuserid+"&mobile="+phone+"&realname="+adminrealname,
					        type: 'get', 
					        dataType: 'json',  
					        success: function (data) {
					          if (data.code == 10001) {
					          	  layer.confirm(data.msg, {
			    					  btn: ['确定']
			    				  }, function(){
			    					  table.reload("adminuserid", {
				    		                where: {
				    		                	keyword:data.code=='10001'
				    		                }
				    		          });
			    					  layer.closeAll();
			    				  });	
	    				  
					          }
					          else{
					        	  layer.alert(data.msg, {icon: 2});
					        	  return false;
					          }
					        }
						});
					});
			    }
			    if(obj.event === 'deladminuser'){	  
			    	var userid=data.userid;
			    	layer.confirm('你确定要删除吗？', {
			    		  btn: ['确定','取消'] 
			    		}, function(){
			    	    	$.ajax({
			        			url: '../sysadminusermanager/deleteadminuser?userid='+userid,  
			        	        type: 'get', 
			        	        dataType: 'json',  
			        	        success: function (getdata) {
			        	          if (getdata.code == 10001) { 
			        	        	  layer.alert(getdata.msg, {icon: 6});
			        	        	  table.reload("adminuserid", { //此处是上文提到的 初始化标识id
							              where: {
							            	  keyword:getdata.code == '10001'
							              }
						             });
			        	          }else { 
			        	        	  layer.alert(getdata.msg, {icon: 5});
			        	          }  
			        	        },
			        	        error:function(){
			        	        	layer.alert(getdata.msg, {icon: 5}); 
			        	        }
			        		});
			    		}, function(){layer.msg("取消成功！",{icon:1}); }
			    	);
			    }
		    });
		});
	</script>
</body>
</html>